package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.PurchaseList;
import com.atguigu.jxc.service.PurchaseListGoodsService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;



@RestController
@RequestMapping("/purchaseListGoods")
public class PurchaseListGoodsController {

    @Autowired
    private PurchaseListGoodsService purchaseListGoodsService;


    @RequestMapping("/save")
    @RequiresPermissions(value = "进货入库")
    public ServiceVO save (PurchaseList purchaseList,String purchaseListGoodsStr){
        return purchaseListGoodsService.save(purchaseList,purchaseListGoodsStr);
    }


    @RequestMapping("/list")
    @RequiresPermissions(value = {"进货单据查询","供应商统计"},logical = Logical.OR)
    public Map<String,Object> list (String purchaseNumber,Integer supplierId, Integer state,String sTime,String eTime){
        return purchaseListGoodsService.list(purchaseNumber,supplierId,state,sTime,eTime);
    }

    @RequestMapping("/goodsList")
    @RequiresPermissions(value={"进货单据查询","供应商统计"},logical = Logical.OR)
    public Map<String,Object> goodsList(Integer purchaseListId){
        return purchaseListGoodsService.goodsList(purchaseListId);
    }

    @RequestMapping("/delete")
    @RequiresPermissions(value = "进货单据查询")
    public ServiceVO delete (Integer purchaseListId){
        return  purchaseListGoodsService.delete(purchaseListId);
    }

    @RequestMapping("/updateState")
    @RequiresPermissions(value = "供应商统计")
    public ServiceVO updateState (Integer purchaseListId){
        return purchaseListGoodsService.updateState(purchaseListId);
    }


    @RequestMapping("/count")
    @RequiresPermissions(value = "商品采购统计")
    public String count (String sTime,String eTime,Integer goodsTypeId,String codeOrName){
        return purchaseListGoodsService.count(sTime,eTime,goodsTypeId,codeOrName);
    }



}
